package com.springcloud.entities;

import lombok.Data;
import java.io.Serializable;

@Data
public class ReturnResult<T> implements Serializable {
	private Integer code; // 异常码
	private String message; // 提示信息
	private T data; // 返回数据
	/***
	 * 成功不带数据
	 * @return
	 */
	public static ReturnResult success(){
		ReturnResult returnResult=new ReturnResult();
		returnResult.setCode(0);
		return returnResult;
	}
	/***
	 * 成功带数据
	 * @return
	 */
	public static ReturnResult success(Object data){
		ReturnResult returnResult=new ReturnResult();
		returnResult.setCode(0);
		returnResult.setData(data);
		return returnResult;
	}
	/***
	 * 失败
	 * @return
	 */
	public static ReturnResult fail(Integer code,String message){
		ReturnResult returnResult=new ReturnResult();
		returnResult.setCode(code);
		returnResult.setMessage(message);
		return returnResult;
	}

}